package cn.sytton.taffecloud.service.job.service;

import cn.sytton.taffecloud.common.db.model.PageParam;
import cn.sytton.taffecloud.service.job.entity.JobEntity;
import cn.sytton.taffecloud.service.job.exception.TaskException;
import com.github.pagehelper.PageInfo;
import org.quartz.SchedulerException;

import java.util.Map;

/**
 * 定时任务服务层接口
 *
 * @author skyrock
 */
public interface IJobService {

    PageInfo<JobEntity> findListPage(PageParam pp);

    JobEntity findById(String id);

    void create(JobEntity entity) throws SchedulerException, TaskException;

    void update(JobEntity entity) throws SchedulerException, TaskException;

    void delete(String... ids) throws SchedulerException, TaskException;

    /**
     * 修改定时任务运行状态
     * @param entity 对象
     */
    void updateStatus(JobEntity entity) throws SchedulerException;

    /**
     * 定时任务立即执行一次
     * @param entity 对象
     */
    void run(JobEntity entity) throws SchedulerException;

    /**
     * 查询任务运行统计信息
     * @param jobId 任务ID
     * @return 统计信息
     */
    Map<String, Object> findRunInfo(String jobId);
}
